package com.vip.mongofile.model;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.bson.types.Binary;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

/**
 * File 文档类.
 * 
 * @since 1.0.0 2017年3月28日
 * @author <a href="https://waylau.com">Way Lau</a> 
 */
@Document
@Getter
@Setter
@Accessors(chain = true)
public class MongoFile {
    /**
     * 主键
     */
	@Id
	private String id;
    /**
     * 大文件管理GridFS的ID
     */
    private String gridFsId;
    /**
     * 文件名称
     */
    private String name;
    /**
     * 文件类型
     */
    private String contentType;
    /**
     * 文件MD5
     */
    private String md5;
    /**
     * 文件路径
     */
    private String path;
    /**
     * 文件后缀
     */
    private String suffix;
    /**
     * 文件大小：单位：B
     */
    private long size;
    /**
     * 文件内容
     */
    private Binary content;
    /**
     * 上传时间
     */
    private Date uploadDate;

    protected MongoFile() {
    }

    public MongoFile(String name, String contentType, long size, Binary content) {
    	this.name = name;
    	this.contentType = contentType;
    	this.size = size;
    	this.uploadDate = new Date();
    	this.content = content;
    }

    public MongoFile(String name, String contentType, long size, String suffix) {
        this.name = name;
        this.contentType = contentType;
        this.size = size;
        this.uploadDate = new Date();
        this.suffix = suffix;
    }

}
